﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Lonewolf.Infrastructure
{
    /// <summary>
    /// JSON-API接口返回JSON字符串
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class JsonResult<T> where T : class
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public object code { get; set; } = 200;
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool success { get; set; } = false;
        /// <summary>
        /// 提示信息
        /// </summary>
        public string message { get; set; }
        /// <summary>
        /// 数据实体
        /// </summary>
        public T Entity { get; set; }
        /// <summary>
        /// 数据集
        /// </summary>
        public List<T> data { get; set; }
        /// <summary>
        /// 记录条数。
        /// </summary>
        public long count { get; set; }
        /// <summary>
        /// 响应时间
        /// </summary>
        public string time { get; set; }
    }

    public static class Result
    {
        /// <summary>
        /// 全局成功
        /// </summary>
        /// <returns></returns>
        public static string Success()
        {
            return "保存成功！";
        }
        /// <summary>
        /// 全局失败
        /// </summary>
        /// <returns></returns>
        public static string Error()
        {
            return "保存失败！";
        }
        /// <summary>
        /// 未找到外键关联数据，保存失败!
        /// </summary>
        /// <returns></returns>
        public static string Wrong()
        {
            return "未找到外键关联数据，保存失败！";
        }
        /// <summary>
        /// 必填项不能为空
        /// </summary>
        /// <returns></returns>
        public static string IsNull()
        {
            return "必填项不能为空，保存失败！";
        }
        /// <summary>
        /// 数据库中已经存在相关数据，不能重复！
        /// </summary>
        /// <returns></returns>
        public static string Repeat()
        {
            return "查询到重复数据，保存失败！";
        }
        /// <summary>
        /// 未查询到待修改数据
        /// </summary>
        /// <returns></returns>
        public static string SelectNull()
        {
            return "未查询到待修改数据，保存失败！";
        }
        /// <summary>
        /// 获取数据成功！
        /// </summary>
        /// <returns></returns>
        public static string GetSuccess()
        {
            return "获取数据成功！";
        }
        /// <summary>
        /// 获取数据失败
        /// </summary>
        /// <returns></returns>
        public static string GetError()
        {
            return "获取数据失败！";
        }
    }
}
